﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Training9
{
    public partial class frmLogin : Form
    {
        public frmLogin()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlOperate obj = new SqlOperate();
            string sql = "select S_password from S_Login where S_username='" + textBox1.Text + "'";
            string sqlsel = "";
            SqlDataReader sdr = obj.GetDR(sql);

             

            while (sdr.Read())
            {
                sqlsel = sdr.GetValue(0).ToString();
            }
            
            if (textBox2.Text == sqlsel && sqlsel!="")
            {
                frmMain.login = true;
                this.Close();
            }
            
            else
            { MessageBox.Show("用户、密码错误！", "信息提示", MessageBoxButtons.OK); }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
